<?php $this->load->view("common/page_header");?>
<div id="body_main">	
	<div class="login_header">
		<img class="logo" src="/img/logo2.png" />
		<div class="title">小组管理</div>
		
		<div class="action"><a href="/group/view?group_id=<?php echo $group_id;?>">返回小组</a></div>
		<?php $this->load->view("common/message");?>
		<div class="clear"></div>
	</div>
	<form method="post" action="/group/admin_op" id="groups-form">
	<div class="login_body group_admin">
		<div class="arrow_up" style="left:225px">
			<em>◆</em>
			<span>◆</span>
		</div>
		
		<div class="left set_manager">
			<div class="border_bottom">
				<div class="margin_bottom15"><span class="bold">设置管理员</span><span class="grey">(您最多可设置4名管理员)</span></div>
				<div class="margin_bottom15">请输入设为管理员的会员昵称</div>
				<div class="margin_bottom15">
					<input type="button" id="set-admin" class="right input_button" value="设为管理员" />
					<input type="text" name="nick" id="nick" class="input_text" style="width:180px"/>
				</div>
			</div>
			<?php if(!empty($admins)) {?>
			<div class="border_bottom">
				<div class="margin_top15 margin_bottom15">以下人员已被您设为管理员，您可以选择撤消：</div>
				
				<ul>
					<?php foreach($admins as $admin) { ?>
					<li class="margin_left10 margin_bottom15"><input type="checkbox" name="admins[]" value="<?php echo $admin['user_id'];?>"/><a class="margin_left5" href="/user/show?user_id=<?php echo $admin['user_id']?>"><?php echo $admin['nickname']?></a></li>
					<?php } ?>
				</ul>
			</div>
			<input type="button" id="cancel-admin" class="margin_top15 input_button right" value="撤消管理员" />
			<?php }?>
		</div>
		<div class="right set_member">
			<div class="border_bottom">
				<div class="bold margin_bottom15">踢出小组成员</div>
				<div class="margin_bottom15">请输入要踢出的会员昵称</div>
				<div class="margin_bottom15">
					<input type="text" class="input_text" style="width:180px" name="nick_off" id="nick-off"/>
					<input id="kickoff" type="button" class="input_button margin_left15" value="踢出" />
				</div>
			</div>
			<div class="border_bottom">
				<div class="margin_top15 margin_bottom15"><span class="bold">组员审批：</span><span class="grey">以下人员申请加入小组</span></div>
				<?php if(!empty($v_members)) {?>
				<ul class="group_members">
					<?php foreach($v_members as $member) { ?>
					<li><input type="checkbox" name="v_members[]" value="<?php echo $member['id']?>"/><a class="margin_left5" href="/user/show?user_id=<?php echo $member['user_id']?>"><?php echo $member['nickname'];?></a></li>
					<?php } ?>
				</ul>
				<?php }?>
				<div class="clear"></div>
			</div>
			<div class="margin_top15">
				<input type="button" id="allow" class="input_button right" value="批准为小组成员" />
				<input id="check-all" type="checkbox" />全选
			</div>
		</div>
		<div class="clear"></div>
	</div>
	<input type="hidden" name="action" id="action"></input>
	<input type="hidden" name="group_id"  value="<?php echo $group_id?>"></input>
	</form>
</div>
<script type="text/javascript">
$(document).ready(function(){
	$("#set-admin").click(function() {
		if($("#nick").val() != "") {
			$("#action").val("toadmin");
			$("#groups-form").submit();
		} else {
			alert("请输入用户昵称");
			$("#nick").focus();
		}
	});
	$("#kickoff").click(function() {
		if($("#nick-off").val() != "") {
			$("#action").val("delete");
			$("#groups-form").submit();
		} else {
			alert("请输入用户昵称");
			$("#nick").focus();
		}
	});
	$("#check-all").click(function() {
		if ($(this).attr("checked") == 'checked') {
			$("input[name='v_members[]']").attr("checked", true);
		} else {
			$("input[name='v_members[]']").attr("checked", false);
		}
	});
	$("#cancel-admin").click(function() {
		var is_checked = false;
		$("input[name='admins[]']").each(function(){
			if ($(this).attr("checked") == 'checked') {
				is_checked = true;
			}
		});
		if(is_checked) {
			$("#action").val("removeadmin");
			$("#groups-form").submit();
		} else {
			alert("请选择要取消的用户");
		}
	});
	$("#allow").click(function() {
		var is_checked = false;
		$("input[name='v_members[]']").each(function(){
			if ($(this).attr("checked") == 'checked') {
				is_checked = true;
			}
		});
		if(is_checked) {
			$("#action").val("allow");
			$("#groups-form").submit();
		} else {
			alert("请选择用户");
		}
	});
});
</script>
<?php $this->load->view("common/footer");?>		
<?php $this->load->view("common/page_footer");?>